<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AlterChannelToCouponTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('coupon', function (Blueprint $table) {
            $table->string('channel',50)->default('oil_recharge')->comment('优惠券使用渠道all/oil_recharge/mobile_recharge')->after('title');
        });

        Schema::table('user_coupon', function (Blueprint $table) {
            $table->string('channel',50)->default('oil_recharge')->comment('优惠券使用渠道all/oil_recharge/mobile_recharge')->after('title');
            $table->index(['channel']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('coupon', function (Blueprint $table) {
            $table->dropColumn(['channel']);
        });

        Schema::table('user_coupon', function (Blueprint $table) {
            $table->dropIndex(['channel']);
            $table->dropColumn(['channel']);
        });
    }
}
